/*
 * TesterMain.h
 *
 *  Created on: Jan 7, 2011
 *      Author: dt
 */

#ifndef TESTERMAIN_H_
#define TESTERMAIN_H_

#include "talk/examples/monarch-common/XMPPCallback.h"
#include "talk/examples/monarch-common/ConnectionCallback.h"
#include "talk/examples/monarch-common/PipeEp.h"
#include "joystick.pb.h"



class TesterMain: public XMPPCallback, public ConnectionCallback
{
public:
  TesterMain(std::string& username, std::string& password,  std::string& xmppServerAddress, bool& debug, unsigned int& msgsize, unsigned int& msginterval);

  virtual void onRosterAdd(std::string& username);

  virtual void onXmppConnected();

  virtual void onChatMessageReceived(std::string& from, std::string& msg);

  virtual ConnectionCallback* onIncomingTunnelRequest();

  virtual void onTunnelConnect(PipeEp* p);

  virtual void onTunnelDisconnect(PipeEp* p, bool withError);

  virtual void onDataRecive(PipeEp* p, const char* buf, size_t size);

  cricket::MediaEngine* CreateMonarchClientMediaEngine(const char* voice_in,
                                              const char* voice_out,
                                              const char* video_in,
                                              const char* video_out);

private:
  MonarchController *monarch_controller_;

  monarch::ControllerState *controller_state_;
  const monarch::ControllerState_KeyEvent *key_event_;
  PipeEp* pipe_;
  int video_pipe_,send_pipe_,rcv_pipe_,force_delay;
  unsigned int msgsize_;
  unsigned int msginterval_;

  cricket::MediaEngine *media_engine_;

  //struct control_data cd, *cdata;
  int stop;
  //unsigned char *g_buf;
  size_t read_buf_len_;
  char write_buf_[1024*64];
  size_t write_buf_len_;
};

#endif /* TESTERMAIN_H_ */
